<?php
namespace app\web\model;



use think\Model;

/**
* 
*/
class Base extends Model
{
	protected $autoWriteTimestamp = true;
	
	public static function getSelectAll($where=null,$field='',$pk='id')
	{	
		if(!$field){
			$field_name = get_called_class();
			$field = strtolower(substr($field_name,strripos($field_name,"\\")+1)) . '_name';
		}
		$data = self::where($where)->field($pk.','.$field)->order('id desc')->all()->toArray();
    	$data = array_combine(array_column($data,$pk),array_column($data,$field));
    	return $data;
	}



	public static function taskTechnician()
	{
		return Technician::where([['is_period','=',0],['period_time','>',0],['period_time','<',time()]])->update(['is_period'=>1]);
	}
	public static function taskShop()
	{
		return Shop::where([['is_period','=',0],['period_time','>',0],['period_time','<',time()]])->update(['is_period'=>1]);
	}
}

